# -*- coding: utf-8 -*-
# @Time    : 2020/12/11 上午12:08
# @Author  : lilong

import torch

n = 4
x = torch.ones(n)            # 创建对角矩阵n*n
print(x)
print(x.shape)
ou = x.expand((1, n, n))    # 扩展维度到b维
print(ou[0])
print(torch.tril(ou[0], diagonal=0))
print("-------------------------------")

import numpy as np
aa = np.array([

        [
            [1, 2, 3, 6],
            [3, 4, 5, 6],
            [3, 4, 5, 7]
        ],

        [
            [3, 5, 6, 8],
            [8, 5, 3, 5],
            [3, 4, 5, 3]
        ]
    ]
)
a_tor = torch.from_numpy(aa)
print(a_tor.shape[1])
print(torch.arange(1, 3))
print(torch.ones(3, 3))
mm = torch.tril(torch.ones(3, 3), diagonal=0)
print("mm1:\n", mm, mm.shape)
print("mm2:\n", mm[None, None], mm[None, None].shape)
print()
print(torch.triu(torch.ones(3, 3), diagonal=0))
